package org.willthink.controller;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.willthink.service.main.MainService;

@Controller
@RequestMapping("/main")
public class MainController{

	private MainService service;
	
	public void setService(MainService service) {
		this.service = service;
	}
	
	@RequestMapping(value="/baseMenu.think")
	public ModelAndView baseMenu(HttpServletRequest request, HttpServletResponse response){
		ModelAndView mav = new ModelAndView();
		List list = new ArrayList();
		
		try {
			list = service.getMenuList("3");
		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		
		mav.addObject("list", list);
		mav.setViewName("main/basePage");
		
		return mav;
	}
	
	@RequestMapping(value="/mainView.think")
	public ModelAndView mainView(HttpServletRequest request, HttpServletResponse response){
		ModelAndView mav = new ModelAndView();
		
		mav.setViewName("main/mainPage");
		
		return mav;
	}
}
